﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AWSS3ToAzureBlob
{
    [ExcludeFromCodeCoverage]
    class TraceHelper
    {
        private static TraceSwitch _traceSwitch = new TraceSwitch("TraceLevelSwitch", null);
        public static void TraceInformation(string message, params object[] args)
        {
            if (_traceSwitch.TraceInfo)
            {
                Trace.WriteLine(FormatMessage("Information", message, args));
            }
        }

        public static void TraceError(string message, params object[] args)
        {
            if (_traceSwitch.TraceError)
            {
                Trace.WriteLine(FormatMessage("Error", message, args));
            }
        }

        public static void TraceVerbose(string message, params object[] args)
        {
            if (_traceSwitch.TraceVerbose)
            {
                Trace.WriteLine(FormatMessage("Verbose", message, args));
            }
        }

        private static string FormatMessage(string category, string message, params object[] args)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("[{0}]", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            sb.AppendFormat("[{0}]", category);
            sb.AppendFormat(message, args);

            return sb.ToString();
        }
    }
}